using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace offline2048
{
    public class PlayerPrefsManager
    {
        public static string USER_LAYER_NAME = "User_Layer_Name";
        public static string USER_NO_AD_TEN_TIMES = "User_No_Ad_Ten_Times";//连续10次领取奖励不看广告
        //主玩法存储================================================================================
        public static string PLAYER_CURRENT_DOLLER_COUNT = "Player_Current_Doller_Count";//当局doller数量
        public static string PLAYER_HISTROY_DOLLER_COUNT = "Player_Histrory_Doller_Count";//历史最高doller数量
        //新手引导用================================================================================
        public static string PLAYER_GUIDE_SHOW_ID = "Player_Guide_Show_Id";//新手引导是否显示

        public static string FISRT_DAY_WATCH_REWARD_CM_COUNT = "First_Day_Watch_Reward_CM_Count";
        public static string FISRT_DAY_WATCH_REWARD_CM_COUNT_DAY = "First_Day_Watch_Reward_CM_Count_Day";
        
        //3个登陆日累积看插屏的次数
        public static string THREE_DAY_WATCH_INTER_CM_COUNT = "Three_Day_Watch_Inter_CM_Count";
        public static string THREE_DAY_WATCH_INTER_CM_COUNT_LAST_DAY = "Three_Day_Watch_Inter_CM_Count_Last_Day";//上一次的日期
        public static string THREE_DAY_WATCH_INTER_CM_COUNT_DAY_COUNT = "Three_Day_Watch_Inter_CM_Count_Count";//累积的天数
        //
        public static string USER_CHANGE_LAYER_TIME = "User_Change_Layer_Time";
        public static void SetInt(string key, int value)
        {
            if (key.Equals(PLAYER_HISTROY_DOLLER_COUNT))
            {
                GameManager.instance.CurrentData.CoinNumber = value;
            }
            else
            {
                PlayerPrefs.SetInt(key, value);
                PlayerPrefs.Save();
            }
        }
    
        public static void SetString(string key, string value)
        {
            PlayerPrefs.SetString(key, value);
            PlayerPrefs.Save();
        }
    
        public static void SetFloat(string key, float value)
        {
            PlayerPrefs.SetFloat(key, value);
            PlayerPrefs.Save();
        }
    
        public static int GetInt(string key, int defaultValue = 0)
        {
            if (key.Equals(PLAYER_HISTROY_DOLLER_COUNT))
            {
                return GameManager.instance.CurrentData.CoinNumber;
            }
            else
            {
                return PlayerPrefs.GetInt(key, defaultValue);
            }
        }
    
        public static string GetString(string key, string defaultValue = "")
        {
            return PlayerPrefs.GetString(key, defaultValue);
        }
    
        public static float GetFloat(string key, float defaultValue = 0f)
        {
            return PlayerPrefs.GetFloat(key, defaultValue);
        }
        
        public static void ReSetFloat(string key, float defaultValue = 0f)
        {
            PlayerPrefs.SetFloat(key, defaultValue);
        }
    
        public static void ReSetInt(string key, int defaultValue = 0)
        {
            PlayerPrefs.SetInt(key, defaultValue);
        }
    
        public static void ReSetString(string key, string defaultValue = "")
        {
            PlayerPrefs.SetString(key, defaultValue);
        }
        
    }
}


